@extends('admin.layout.index')
@section('js')
<script src="/web/js/libs/jquery-1.8.3.min.js"></script>
<script>
a = null;
$(function (){
     $('.cate select').blur(function (){
          var val = $(this).val();
          $(this).nextAll().remove();
          $(this).after("<select class='aa'></select>")
          $.get('/admin/carousel/cate2', 'id='+val,function (msg){
               console.log(msg);
               $.each(msg, function (i, n){
                    $("<option value='"+n.id+"'>"+n.cname+"</option>").appendTo('.aa'); 
               })
          },'json');
     $('.aa').blur(function (){
          val = $(this).val();
          $('[name=gid]').empty();
          $.get('/admin/goods/cate','tid='+val, function (msg){
               //console.log(eval(msg));
               $.each(msg, function (i, n){
                    var arr = new Array();
                    $.each(n,function (ii, nn){      
                         arr.push(nn);                 
                    })
                    $('[name=gid]').append("<option value='"+arr[0]+"'>"+arr[1]+"</option>");
                 });
             },'json')

     })
     })
})
</script>
@endsection
@section('content')
<div class="mws-panel grid_8">
 	<div class="mws-panel-header">
     	<span>轮播图添加</span>
     </div>
     <div class="mws-panel-body no-padding">
     	<form action="/admin/carousel/insert" class="mws-form" method='post' enctype="multipart/form-data">
     		{{csrf_field()}}
     		<div class="mws-form-inline">
     			<div class="mws-form-row">
     				<label class="mws-form-label">轮播图类型</label>
     				<div class="mws-form-item" style="width:20%">
     					<select class="large" name="ctype">
                                   <option value="首页轮播图">--首页轮播图--</option>
                              </select>
     				</div>
     			</div>
     			<div class="mws-form-row">
     				<label class="mws-form-label">商品分类</label>
     				<div class="mws-form-item cate" style="width:20%">
     					<select class="large" name="pid">
     					<option>--请选择--</option>
     					@foreach($data as $k => $v)
     						<option value="{{$v['id']}}">{{$v['cname']}}</option>
     					@endforeach
     					</select>
     				</div>
     			</div>
                    <div class="mws-form-row">
                         <label class="mws-form-label">商品货号</label>
                         <div class="mws-form-item" style="width:20%">
                              <select class="large" name="gid">
                              </select>
                         </div>
                    </div>
                    <div class="mws-form-row">
                         <label class="mws-form-label">商品照片</label>
                         <div class="mws-form-item" style="width:20%">
                              <input type="file" name="cpic">
                         </div>
                    </div>
     		</div>
     		<div class="mws-button-row">
     			<input type="submit" class="btn btn-danger" value="添加">
     			<input type="reset" class="btn " value="重置">
     		</div>
     	</form>
     </div>    	
 </div>
@endsection
